home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Win Platinum
/
Win Platinum.iso
/
games
/
hyperoid
/
list.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-12
|
1KB
|
62 lines
//
// LIST - list processing functions for orbiter
//
// Version: 1.0 Copyright (C) 1990, Hutchins Software
// Author: Edward Hutchins
// Revisions:
//
#include "orbiter.h"
//
// AddHead - add an object to the head of a list
//
VOID FAR PASCAL AddHead( NPLIST npList, NPNODE npNode )
{
if (npList->npHead)
{
npNode->npNext = npList->npHead;
npNode->npPrev = NULL;
npList->npHead = (npList->npHead->npPrev = npNode);
}
else // add to an empty list
{
npList->npHead = npList->npTail = npNode;
npNode->npNext = npNode->npPrev = NULL;
}
}
//
// RemHead - remove the first element in a list
//
NPNODE FAR PASCAL RemHead( NPLIST npList )
{
if (npList->npHead)
{
NPNODE npNode = npList->npHead;
if (npList->npTail != npNode)
{
npList->npHead = npNode->npNext;
npNode->npNext->npPrev = NULL;
}
else npList->npHead = npList->npTail = NULL;
return( npNode );
}
else return( NULL );
}
//
// Remove - remove an arbitrary element from a list
//
VOID FAR PASCAL Remove( NPLIST npList, NPNODE npNode )
{
if (npNode->npPrev) npNode->npPrev->npNext = npNode->npNext;
else npList->npHead = npNode->npNext;
if (npNode->npNext) npNode->npNext->npPrev = npNode->npPrev;
else npList->npTail = npNode->npPrev;
}